package com.bjfu.mapper;

import com.bjfu.model.Team;
import com.bjfu.model.UserInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TeamMapper {

    // 插入一个新的团队
    @Insert("INSERT INTO team (name, research_field, description, admin_id) VALUES (#{name}, #{researchField}, #{description}, #{adminId})")
    @Options(useGeneratedKeys = true, keyProperty = "teamId", keyColumn = "team_id")
    void insertTeam(Team team);

    // 更新团队信息
    @Update("UPDATE team SET name = #{name}, research_field = #{researchField}, description = #{description}, admin_id = #{adminId},created_time=#{createdTime} WHERE team_id = #{teamId}")
    int updateTeam(Team team);

    // 删除团队
    @Delete("DELETE FROM team WHERE team_id = #{teamId}")
    void deleteTeam(Long teamId);

    // 根据团队 ID 获取团队
    @Select("SELECT * FROM team WHERE team_id = #{teamId}")
    Team getTeamById(Long teamId);

    // 获取所有团队信息
    @Select("SELECT * FROM team where team_id =1")
    List<Team> getTeam();


}
